﻿using System;
using System.Web.Routing;
using System.Web.DynamicData;
using CSS.Common;
using CSS.Action;

namespace MedLife
{
    public class Global : System.Web.HttpApplication
    {
        private static MetaModel s_defaultModel = new MetaModel();
        public static MetaModel DefaultModel
        {
            get
            {
                return s_defaultModel;
            }
        }
        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            string UrlExtention = AppSettings.GetString(Constants.URL_EXTENTION);
            routes.MapPageRoute("Home", "trang-chu" + UrlExtention, "~/Home/Pages/Home.aspx");
            routes.MapPageRoute("AdminCP", "AdminCP/Default.aspx", "~/AdminCP/Pages/Default.aspx");
            routes.MapPageRoute("News", "tin-tuc" + UrlExtention, "~/Home/Pages/News.aspx");
            routes.MapPageRoute("NewsByCate", "tin-tuc/{catename}-{id}" + UrlExtention, "~/Home/Pages/NewsByCategory.aspx");
            routes.MapPageRoute("NewsDetail", "tin-tuc/chi-tiet/{title}-{id}" + UrlExtention, "~/Home/Pages/NewsDetail.aspx");
            routes.MapPageRoute("GroupBuy", "mua-chung" + UrlExtention, "~/Home/Pages/GroupBuy.aspx");
            routes.MapPageRoute("Contact", "lien-he" + UrlExtention, "~/Home/Pages/Contact.aspx");
            routes.MapPageRoute("BuyMedicineByForm", "mua-thuoc-theo-don" + UrlExtention, "~/Home/Pages/BuyMedicineByForm.aspx");
            routes.MapPageRoute("Products", "tim-thuoc" + UrlExtention, "~/Home/Pages/Product.aspx");
            routes.MapPageRoute("Products2", "tim-thuoc-theo-loai" + UrlExtention, "~/Home/Pages/ProductByCategory.aspx");
            routes.MapPageRoute("ProductsByCategory", "tim-thuoc/{cattitle}-{id}" + UrlExtention, "~/Home/Pages/ProductByCategory.aspx");
            routes.MapPageRoute("ProductDetail", "san-pham/{title}-{id}" + UrlExtention, "~/Home/Pages/ProductDetail.aspx");
            routes.MapPageRoute("AddToCartProcess", "mua-hang-{id}" + UrlExtention, "~/Home/Pages/AddToCartProcess.aspx");//
            routes.MapPageRoute("ShopCart", "gio-hang" + UrlExtention, "~/Home/Pages/ShopCart.aspx");//
            routes.MapPageRoute("Login", "dang-nhap" + UrlExtention, "~/Home/Pages/Login.aspx");
            routes.MapPageRoute("Register", "dang-ky" + UrlExtention, "~/Home/Pages/Register.aspx");
            routes.MapPageRoute("Logout", "thoat" + UrlExtention, "~/Home/Pages/Logout.aspx");
            routes.MapPageRoute("thanhtoan", "thanh-toan" + UrlExtention, "~/Home/Pages/PaymentProcess.aspx");
            routes.MapPageRoute("thanhcong", "Thanh-toan-thanh-cong" + UrlExtention, "~/Home/Pages/Success.aspx");
            routes.MapPageRoute("gioithieu", "gioi-thieu" + UrlExtention, "~/Home/Pages/About.aspx");
            routes.MapPageRoute("hotrokhachhang", "ho-tro-khach-hang" + UrlExtention, "~/Home/Pages/CustommerSupport.aspx");
            routes.MapPageRoute("huongdanthanhtoan", "huong-dan-thanh-toan" + UrlExtention, "~/Home/Pages/CheckoutGuild.aspx");
            routes.MapPageRoute("huongdanmuahang", "huong-dan-mua-hang" + UrlExtention, "~/Home/Pages/BuyGuild.aspx");
            routes.MapPageRoute("huongdantrahang", "huong-dan-tra-hang" + UrlExtention, "~/Home/Pages/DeliveryGuild.aspx");
            routes.MapPageRoute("address", "dia-chi" + UrlExtention, "~/Home/Pages/Address.aspx");
        }

        void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown

        }

        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs

        }

        void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started

        }

        void Session_End(object sender, EventArgs e)
        {
            // Code that runs when a session ends. 
            // Note: The Session_End event is raised only when the sessionstate mode
            // is set to InProc in the Web.config file. If session mode is set to StateServer 
            // or SQLServer, the event is not raised.

        }

    }
}
